package com.widevision.adapter;

import java.util.ArrayList;
import java.util.HashMap;

import net.widevision.android.R;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.widevision.ListActivity.FollowerName;
import com.widevision.utility.ImageLoader;

public class FollowerListAdapter  extends BaseAdapter{
	
	
	private static ArrayList<HashMap<String, String>> data;
	public ImageLoader imageLoader; 
 
    public Activity activity;
    public LayoutInflater inflater;
 
    public FollowerListAdapter(Activity a, ArrayList<HashMap<String, String>> d)
    {
    	 activity = a;
         data=d;
         inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         imageLoader=new ImageLoader(activity.getApplicationContext());
    }
 
    
    public int getCount()
    {
    	return data.size();
    }
   
    public Object getItem(int position) 
    {
      	 return position;
    }
   
    
    public long getItemId(int position)
    {
      	return position;
    }
      
 
    public static class ViewHolder
    {
        TextView name;
        ImageView image;
        TextView userId;
       
    }
 
 
    public View getView(int position, View convertView, ViewGroup parent)
    {
        final ViewHolder holder=new ViewHolder();
        if(convertView==null)
        
            convertView = inflater.inflate(R.layout.followerlistitem, null);
            holder.image = (ImageView) convertView.findViewById(R.id.frndimg);
            holder.name = (TextView) convertView.findViewById(R.id.frndname);
            holder.userId=(TextView) convertView.findViewById(R.id.userId);
            
            HashMap<String, String> follrmap = new HashMap<String, String>();
            
            follrmap = data.get(position);
            
            //SETTING ALL ITEM VALUES
       
	        holder.name.setText(follrmap.get(FollowerName.FOLLR_NAME));
	        imageLoader.DisplayImage(follrmap.get(FollowerName.FOLLR_THUMB_URL), holder.image);
	        holder.userId.setText(follrmap.get(FollowerName.FOLLR_ID));
	        
	        convertView.setTag(holder);
	        return convertView;
        
 
    }
}

